<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>维保管理</title>
	<meta name="viewport"  content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/bootstrap/css/bootstrap-multiselect.css">
  	<link rel="stylesheet" type="text/css" href="${path}/resource/css/ysrmain.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/css/gzfx.css">
	<link rel="stylesheet" href="${path}/resource/css/allEquipment.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/css/myLayer.css">
	<link rel="stylesheet" type="text/css" href="${path}/resource/plugins/date/bootstrap-datetimepicker.min.css" >
	<script src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap.min.js"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
	<script src="${path}/resource/plugins/date/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
	<script type="text/javascript" src="${path}/resource/js/echarts.min.js"></script>	
	<script type="text/javascript" src="${path}/resource/plugins/bootstrap/js/bootstrap-multiselect.js"></script>
	<script type="text/javascript"></script>
	<style type="text/css">
		.back-w{
			background:#fff;
			border:none;
			border:1px solid #999;
		}
		.color-3{
			color:#333;
		}
		.time-input2{
			color:#333;
		}
		.multiselect-container{
			max-height: 300px;
   			overflow-y: scroll;
		}
		.multiselect-selected-text {
		    overflow: hidden;
		    width: 100%;
		    white-space: nowrap;
		    text-overflow: ellipsis;
		}
	</style>
</head>
<body>
	
	<!-- 头部 -->
	<!-- 开始 -->
	<jsp:include page="./top_nav.jsp"></jsp:include>
	<!-- 头部结束 -->
    <!-- 右侧内容区域 -->
    <div class="right-content  container-fluid">
    	<div class="row layer">
    		<!-- 主要图表区域 -->
			<div class="layer1">
	    		<div class=" row right-nav">
		    			<div class="title-name">
		    				<span>变频器维保记录统计</span>
		    				
		    			</div>
		    			<div class=" right nav-over padding-r-1  ">
		    				 <a href="${path}/monitor/redirect/repairInput" class="add-a">新增</a>
		    				         <button class=" search-btn float-r" type="button" onclick="search();"></button>
						      <input id="require" type="text" placeholder="请输入检索的故障信息" class="back-m1 search-input float-r search back-m1">					      										      			
		    			</div>	    			
		    	</div>	
			  <!-- Table -->
			  <div class="table-div content-img">
				  <table id="listtable" class="table table-striped" style="font-size: 13px">
				  	  <tr>
				  	  	  <th>记录编号</th>
						  <th>变频器序列号</th>
						  <th>设备型号</th>
						  <th>所在城市</th>
						  <th>详细</th>
						  <th>删除</th>
					  </tr>
					  <tr>
					  	  <td>1</td>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td>风机接触器无法关闭</td>
						  <td>珠海市</td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
					  	  <td>2</td>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td>风机接触器无法关闭</td>
						  <td>珠海市</td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
					  	  <td>3</td>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td>风机接触器无法关闭</td>
						  <td>珠海市</td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
					  <tr>
					  	  <td>4</td>
						  <td><a class="color-w" href="<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum=0181413c">0181413c</a></td>
						  <td>风机接触器无法关闭</td>
						  <td>珠海市</td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbmsg.png"></td>
						  <td><img class="table-icon" alt="" src="${path}/resource/images/sbsc.png"></td>
					  </tr>
				  </table>
			  </div>
			  <!-- 分页 -->
			  <div id="fenye" class="pagers">
			  	<nav class="float-r padding-3">
			  	  <ul class="pagination">
			  	    <li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>
				    <li class="active yema"><a href="javascript:void(0);">1</a></li>
				    <li class="yema"><a href="javascript:void(0);">2</a></li>
				    <li class="yema"><a href="javascript:void(0);">3</a></li>
				    <li class="yema"><a href="javascript:void(0);">4</a></li>
				    <li class="yema"><a href="javascript:void(0);">5</a></li>
				    <li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>
			  	  </ul>
			  	</nav>
			  </div>
			</div>
			<!--删除弹出层-->
			<div class="layer2 layer-remove">
				<div class="layer-content">
					<div class="layer-msg">
						<div>确定删除该条记录?
						</div>
					</div>
					<div class="layer-btn">
						<div class="sure2 delBtn" id="delSure"><a href="javascript:void(0)" class="color-w">确定</a></div>
						<div class="cancel2 delBtn" id="delCancel"><a href="javascript:void(0)" class="color-w">取消</a></div>
					</div>					
				</div>
			</div>
			<!--详情弹出层-->
			<div class="layer2 ">
				<div class="layer-content">
				<form id="dataForm" class="input-form">
					<div class="layer-top1">
						<div>
							维保记录<span id="id">9</span>详细信息
						</div>
					</div>
					<input type="hidden" name="id">
					<div class="layer-body">
						<div class="input-list">
							<div class="div-group5">
							    <label class="g-label">故障日期:</label>
							    <div class="g-input">
							    	 <input name="startTime" type="text" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2" placeholder="请选择开始日期" class="form_date time-input2 input-text" id="datetimepicker1" data-date-format="yyyy-mm-dd ">	
					     		   	<span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
							    </div>
					  		</div>
						  	<div class="div-group5">
							    <label class="g-label">出厂序号:</label>
							    <div class="g-input">
							    	<select id="serialNum" name="serialNum">
							    		<option value=""></option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">产品型号:</label>
							    <div class="g-input">
							    	<input readonly="readonly" placeholder="请检查出厂序号" id="powerLevelType" type="text" class="input-text">
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">安装城市:</label>
							    <div class="g-input">
							    	<input readonly="readonly" placeholder="请检查出厂序号" id="cityArea" type="text" class="input-text">
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">故障数量:</label>
							    <div class="g-input">
							    	<input name="faultNum" type="text" class="input-text">
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">完成日期:</label>
							    <div class="g-input">
							    	<input name="endTime" type="text" readonly="readonly" data-link-format="yyyy-mm-dd" data-link-field="dtp_input2" placeholder="请选择结束日期" class="form_date time-input2 input-text" id="datetimepicker2" data-date-format="yyyy-mm-dd ">
					     			<span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">所属部件:</label>
							    <div class="g-input">
							    	<select id="belongPart" name="belongPart" multiple="multiple">
							    		
							    		<option value="功率模块">功率模块</option>
										<option value="控制系统">控制系统</option>
										<option value="变流器其他">变流器其他</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">故障零件:</label>
							    <div class="g-input">
							    	<select id="faultElement" name="faultElement" multiple="multiple">
							    		<option value="">—请选择—</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">故障代码 :</label>
							    <div class="g-input">
							    	<select id="faultCode" name="faultCode" multiple="multiple">
							    		<option value="">—请选择—</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">故障工况:</label>
							    <div class="g-input">
							    	<select name="faultPhase">
							    		<option value="">—请选择—</option>
										<option value="未上电">未上电</option>
										<option value="初始化">初始化</option>
										<option value="充电合主断">充电合主断</option>
										<option value="待机状态">待机状态</option>
										<option value="运行工况">运行工况</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">投运日期:</label>
							    <div class="g-input">
							    	 <input readonly="readonly"  id="operationDate" type="text" class="input-text">
					     		     <span class="span-date"><span class="glyphicon glyphicon-calendar"></span></span>
							    	
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">处理结果:</label>
							    <div class="g-input">
							    	<select name="processRes">
							    		<option value="">—请选择—</option>
										<option value="故障消除">故障消除</option>
										<option value="故障依旧">故障依旧</option>
										<option value="观察运行">观察运行</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">服务类型:</label>
							    <div class="g-input">
							    	<select name="serverType">
							    		<option value="">—请选择—</option>
										<option value="安装">安装</option>
										<option value="调试">调试</option>
										<option value="三包维护">三包维护</option>
										<option value="有偿服务">有偿服务</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">问题类别:</label>
							    <div class="g-input">
							    	<select name="faultType">
							    		<option value="">—请选择—</option>
										<option value="设计问题">设计问题</option>
										<option value="工艺制造">工艺制造</option>
										<option value="供应质量">供应质量</option>
										<option value="系统问题">系统问题</option>
										<option value="包装运输">包装运输</option>
										<option value="操作维护">操作维护</option>
										<option value="其他">其他</option>
							    	</select>
							    </div>
						  	</div>
						  	<div class="div-group5">
							    <label class="g-label">售后人员:</label>
							    <div class="g-input">
							    	<select name="repairman">
							    		<option value="">—请选择—</option>
										<option value="李易(20129070)">李易(20129070)</option>
										<option value="李军伟(20080267)">李军伟(20080267)</option>
										<option value="邓德新(20121667)">邓德新(20121667)</option>
										<option value="陈昌佳(20105321)">陈昌佳(20105321)</option>
										<option value="何林桂(20101112)">何林桂(20101112)</option>
							    	</select>
							    </div>
						  	</div>
				  		</div>
				  		<div class="line-input">
				  			<span>故障现象:</span><br>
				  			<input name="faultDesc" type="text" placeholder="正常">
				  		</div>
				  		<div class="line-input">
				  			<span>处理措施:</span><br>
				  			<input name="processMeth" type="text" placeholder="正常">
				  		</div>
				  		<div class="line-input">
				  			<span>故障原因:</span><br>
				  			<input name="faultCause" type="text" placeholder="正常">
				  		</div>	
				  		<div class="line-input">
				  			<span>备注信息:</span><br>
				  			<input name="remark" type="text" placeholder="正常">
				  		</div>	
				  		<div class="">
				  			<span >设备详址:</span>
				  			<input id="locationDetail" class="left-input" type="text" >
				  			<span>设计人员</span>
<!-- 				  			<input class="right-input"type="text"><br> -->
				  			<select name="designer">
					  			<option value=>——— 请选择 ———</option>
		                        <option value="刘斐（20080238）">刘斐（20080238）</option>
		                        <option value="黄启钊（20142844）">黄启钊（20142844）</option>
		                        <option value="姚大为（20107140）">姚大为（20107140）</option>
		                        <option value="韩志成（20095124）">韩志成（20095124）</option>
		                        <option value="吴顶峰（20105501）">吴顶峰（20105501）</option>
	                        </select>
				  			<div class="a-btn">
					  			<a class="pull-right cancel" href="javascript:void(0)">取消</a>
					  			<a class="pull-right save" href="javascript:void(0)" onclick="update()">保存</a>
				  			</div>
				  			
				  		</div>				  		
					</div>		
				</form>			
				</div>
			</div>
		</div>
    </div>

	


	
</body>
<script type="text/javascript">
$(function(){
	$(".menu-left").children("dl").eq(2).addClass("dl-active");
	attrYemaSearch();
	
	loadSelect();
})
/*时间组件初始化*/
	$(".span-date").click(function(){		
		$(this).prev().focus();
	})
	$('.form_date').datetimepicker({
		    language:  'zh-CN',
		    weekStart: 1,
		    todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView: 2,
			forceParse: 0,
			maxView:4
		});
	/*多选初始化*/
	$(document).ready(function() {
        
        $('#belongPart').multiselect({
       	 buttonWidth: '90%',
       	 buttonClass:'back-w color-3',
       	buttonHeight:'100%',
       	 nonSelectedText:'—请选择—',
       });
        $('#faultElement').multiselect({
          	 buttonWidth: '90%',
          	 buttonHeight:'100%',
          	 buttonClass:'back-w color-3',
          	 nonSelectedText:'—请选择—',
        });
        $('#faultCode').multiselect({
       	 buttonWidth: '90%',
       	 buttonClass:'back-w color-3',
       	 nonSelectedText:'—请选择—',
       	buttonHeight:'100%',
       });
    });
/*删除弹窗*/

/*   $(function(){
 		$(".remove").click(function(){
 			$(".layer-remove").show();
 		});
 		$("#cancel").click(function(){
			
 			$(".layer-remove").hide();
 		})
		
 	}) */
/*详细信息弹窗  */
/*  $(function(){
 	$(".detailedMsg").click(function(){
 		$(".layer2").show();
	})
 	$(".cancel").click(function(){
 		$(".layer2").hide();
 	})	
 }) */

//加载下拉框
function loadSelect() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/initopt',
		data : {
			opttype : 'serialNum'
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {console.log(result);
				var html = '<option value="">—请选择—</option>';
				var ops = eval("(" + result.data.serialNum + ")");
				$.each(ops, function(i) {
					html += ops[i].value;
				});
				$('#serialNum').html('');
				$('#serialNum').append(html);
			} else {
				console.error("获取下拉框数据失败！");
			}
		},
		error : function() {
			console.error("系统错误！");
		}
	});
}
//选择序列号
$('#serialNum').change(function() {
	if($(this).val() != "") {
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/managerdevdetail',
			data : {
				serialNum : $(this).val()
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					$('#powerLevelType').val(result.data.powerLevelType);
					$('#cityArea').val(result.data.cityArea);
					$('#locationDetail').val(result.data.locationDetail);
					$('#operationDate').val(result.data.operationDate);
					if(result.data.powerLevelType != "") {
						$.ajax({
							type : 'POST',
							url : '<%=path%>/manage/sltoptupdate',
							data : {
								opttype : 'faultCode',
								actval : result.data.powerLevelType
							},
							dataType : 'json',
							async : false,
							success : function(result2) {
								if(result2.status == 'OK') {console.log(result2);
									var html = '';
									var ops = eval("(" + result2.data.faultCode + ")");
									$.each(ops, function(i) {
										html += ops[i].value;
									});
									$('#faultCode').html('');
									$('#faultCode').append(html);
									$('#faultCode').multiselect('rebuild');
								}
							}
						});
					}
				} else {
					console.error("获取设备详情数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#powerLevelType').val('');
		$('#cityArea').val('');
		$('#locationDetail').val('');
		$('#operationDate').val('');
		$('#faultCode').html('<option value="">—请选择—</option>');
		$('#faultCode').multiselect('rebuild');
	}
});
//选择所属部件,加载故障零件下拉框
$('select[name="belongPart"]').change(function() {
	if($(this).val() != "" && $(this).val() != null) {
		var val = $(this).val().join(",");
		$.ajax({
			type : 'POST',
			url : '<%=path%>/manage/sltoptupdate',
			data : {
				opttype : 'faultElement',
				actval : val
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					var html = '';
					var ops = eval("(" + result.data.faultElement + ")");
					$.each(ops, function(i) {
						html += ops[i].value;
					});
					$('#faultElement').html('');
					$('#faultElement').append(html);
					$('#faultElement').multiselect('rebuild');
					
				} else {
					console.error("获取下拉框数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	} else {
		$('#faultElement').html('<option value="">—请选择—</option>');
		$('#faultElement').multiselect('rebuild');
	}
});

var curPageNO = 1;
function search() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/manage/managerMatainMana',
		data : {
			require : $("#require").val(),
			pageSize : 10,
			curPageNO : curPageNO
		},
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == "OK") {
				$('#listtable').text('');
				var html = "<tr><th>记录编号</th><th>变频器序列号</th><th>设备型号</th><th>所在城市</th><th>详细</th><th>删除</th></tr>";
				if(result.data.list == "[null]") {
					
				} else { 
					size = result.data.size;
					var list = eval("(" + result.data.list + ")");
					$.each(list, function(i){
						var href = "<%=path%>/manage/redirect/allEquip/faultAnalysis?serialNum="+list[i].serialNum;
						html += '<tr><td>'+list[i].id +
								'</td><td><a class="color-w" href='+href+'>'+list[i].serialNum +
								'</a></td><td>'+list[i].powerLevelType +
								'</td><td>'+list[i].cityArea +
								'</td><td><a href="javascript:void(0);" onclick="mataindetail(\''+list[i].id+'\')"><img class="table-icon" alt="详情" src="${path}/resource/images/sbmsg.png"></a></td>' +
								'<td><a href="javascript:void(0);" onclick="mataindelete(\''+list[i].id+'\')"><img class="table-icon" alt="删除" src="${path}/resource/images/sbsc.png"></a></td></tr>';
// 								'</td><td><img alt="" src="${path}/resource/images/sbmsg.png"></td>' +
// 								'<td><a href="javascript:void(0);" onclick="devdelete('+list[i].serialNum+')"><img alt="" src="${path}/resource/images/sbsc.png"></a></td></tr>';
					});
				}
				$('#listtable').append(html);
			}
		},
		error : function() {
			//alert("系统错误！");
		}
	})
}

//维保详情
function mataindetail(id) {
	if(id != undefined && id != "") {
		$("#id").text(id);
		$('input[name="id"]').val(id);
		$.ajax({
			type : 'POST',
			url : '<%=path%>/monitor/managermataindetail',
			data : {
				id : id
			},
			dataType : 'json',
			async : false,
			success : function(result) {
				if(result.status == 'OK') {console.log(result);
					
					$('input[name="startTime"]').val(result.data.startTime);
					$('#serialNum').val(result.data.serialNum);
					if(result.data.serialNum != undefined && result.data.serialNum != "") {
						$.ajax({
							type : 'POST',
							url : '<%=path%>/manage/managerdevdetail',
							data : {
								serialNum : result.data.serialNum
							},
							dataType : 'json',
							async : false,
							success : function(result2) {
								if(result2.status == 'OK') {
									$('#powerLevelType').val(result2.data.powerLevelType);
									$('#cityArea').val(result2.data.cityArea);
									$('#locationDetail').val(result2.data.locationDetail);
									$('#operationDate').val(result2.data.operationDate);
									if(result2.data.powerLevelType != undefined && result2.data.powerLevelType != "") {
										$.ajax({
											type : 'POST',
											url : '<%=path%>/manage/sltoptupdate',
											data : {
												opttype : 'faultCode',
												actval : result2.data.powerLevelType
											},
											dataType : 'json',
											async : false,
											success : function(result2) {
												if(result2.status == 'OK') {console.log(result2);
													var html = '';
													var ops = eval("(" + result2.data.faultCode + ")");
													$.each(ops, function(i) {
														html += ops[i].value;
													});
													$('#faultCode').html('');
													$('#faultCode').append(html);
													$('#faultCode').multiselect('rebuild');
												}
											}
										});
									}
								} else {
									console.error("获取设备详情数据失败！");
								}
							},
							error : function() {
								console.error("系统错误！");
							}
						});
					}
// 					$('#cityArea').val(result.data.cityArea);
// 					$('#operationDate').val(result.data.operationDate);
// 					$('#locationDetail').val(result.data.locationDetail);
// 					$('#powerLevelType').val(result.data.powerLevelType);
					//$('input[name="faultCode"]').val(result.data.faultCode);
					
					var faultCodes = result.data.faultCode.split(',');
					$.each(faultCodes, function(i) {
						$("#faultCode option[value='" + faultCodes[i] + "'] ").attr("selected", true);  
					});
					$('#faultCode').multiselect('refresh');
					//$('#faultCode').val(result.data.faultCode);
					
					$('input[name="faultNum"]').val(result.data.faultNum);
					$('input[name="endTime"]').val(result.data.endTime);
					
					if(result.data.belongPart != undefined && result.data.belongPart != "") {
						var val = result.data.belongPart;
						
						var belongParts = val.split(',');
						$.each(belongParts, function(i) {
							$("#belongPart option[value='" + belongParts[i] + "'] ").attr("selected", true);  
						});
						$('#belongPart').multiselect('refresh');
					//}
		            
					//$('#belongPart').val(result.data.belongPart);
					//$('input[name="faultElement"]').val(result.data.faultElement);
					//if(result.data.belongPart != undefined && result.data.belongPart != "") {
						//加载故障零件
						$.ajax({
							type : 'POST',
							url : '<%=path%>/manage/sltoptupdate',
							data : {
								opttype : 'faultElement',
								actval : val
							},
							dataType : 'json',
							async : false,
							success : function(result2) {
								if(result2.status == 'OK') {console.log(result2);
									var html = '';
									var ops = eval("(" + result2.data.faultElement + ")");
									$.each(ops, function(i) {
										html += ops[i].value;
									});
									$('#faultElement').html('');
									$('#faultElement').append(html);
									$('#faultElement').multiselect('rebuild');
									
								} else {
									console.error("获取下拉框数据失败！");
								}
							},
							error : function() {
								console.error("系统错误！");
							}
						});
					}
					var faultElements = result.data.faultElement.split(',');
					$.each(faultElements, function(i) {
						$("#faultElement option[value='" + faultElements[i] + "'] ").attr("selected", true);  
					});
					$('#faultElement').multiselect('refresh');
					//$('#faultElement').val(result.data.faultElement);
					
					$('select[name="faultPhase"]').val(result.data.faultPhase);
					$('select[name="processRes"]').val(result.data.processRes);
					$('select[name="serverType"]').val(result.data.serverType);
					$('select[name="faultType"]').val(result.data.faultType);
					$('select[name="repairman"]').val(result.data.repairman);
					
					$('input[name="faultDesc"]').val(result.data.faultDesc);
					$('input[name="processMeth"]').val(result.data.processMeth);
					$('input[name="faultCause"]').val(result.data.faultCause);
					$('input[name="remark"]').val(result.data.remark);
				} else {
					console.error("获取维保详情数据失败！");
				}
			},
			error : function() {
				console.error("系统错误！");
			}
		});
	}
	$(".layer2").show();
}
$(".cancel").click(function(){
	$(".layer2").hide();
});
function update() {
	$.ajax({
		type : 'POST',
		url : '<%=path%>/monitor/managerMatainUpdate',
		data : $('#dataForm').serialize(),
		dataType : 'json',
		async : false,
		success : function(result) {
			if(result.status == 'OK') {
				if(result.data != null && result.data == "true") {
					alert("修改成功！");
					$(".layer2").hide();
					attrYemaSearch();
<%-- 					window.location.href = '<%=path%>/monitor/redirect/equipManage'; --%>
				} else {
					alert("修改失败！");
				}
			}
		}
	});
}

//维保删除
function mataindelete(id) {
	$(".layer-remove").show();
	$(".delBtn").unbind('click');
	
	$(".delBtn").bind('click',function(){
		if(this.id == "delSure") {
			$.ajax({
				type : 'POST',
				url : '<%=path%>/monitor/managermataindelete',
				data : {
					id : id
				},
				dataType : 'json',
				async : false,
				success : function(result) {
					if(result.status == "OK") {
						console.log(result.data);
						if(result.data == "true") {
							alert("删除成功");
							search();
						} else {
							alert("删除失败");
						}
					}
				},
				error : function() {
					//alert("系统错误！");
				}
			});
		}
		$(".layer-remove").hide();
	});
}

//点击页码
function attrYemaSearch() {
	curPageNO = 1;
	search();
	//$('.pagination').html('');
	$('.pagination').html('<li id="goPrev"><a href="javascript:void(0);">&laquo;</a></li>'+
	    '<li id="firstyema" class="active yema"><a href="javascript:void(0);">1</a></li>'+
	    '<li id="goNext"><a href="javascript:void(0);">&raquo;</a></li>');
	if(size > 10) {
		var html = '';
		var yemaToal = (size/10)+1;
		for(var i=2; i<yemaToal; i++) {
			html += '<li class="yema"><a href="javascript:void(0);">'+i+'</a></li>'
		}
		$('#firstyema').after(html);
	}
	attrYeMa();
}
function attrYeMa() {
	$('.yema').click(function() {
		$('.yema').removeClass("active");
		$(this).addClass("active");
		curPageNO = $(this).children('a').text();
		search();
	});
	$('#goPrev').click(function() {
		var prevyema = $(this).nextAll('.active').prev('.yema');
		if(prevyema != null && prevyema.length > 0) {
			$(this).nextAll('.active').removeClass("active");
			prevyema.addClass("active");
			curPageNO = prevyema.children('a').text();
			search();
		}
	});
	$('#goNext').click(function() {
		var nextyema = $(this).prevAll('.active').next('.yema');
		if(nextyema != null && nextyema.length > 0) {
			$(this).prevAll('.active').removeClass("active");
			nextyema.addClass("active");
			curPageNO = nextyema.children('a').text();
			search();
		}
	});
}

</script>
</html>